using System.Linq;
using Framework.Core.Io;
using Framework.Core.Process;
using Framework.Core.Process.Tasks;
using Xunit;

namespace Framework.IntegrationTests
{
    public class RemoteProcessTest
    {
        private readonly RemoteProcessRunner remoteProcessRunner = new RemoteProcessRunner("192.168.1.100", @"s-grumly\vpn", "gkqyapc");

        private readonly RemoteProcessController remoteProcessController = new RemoteProcessController("192.168.1.100", @"s-grumly\vpn", "gkqyapc");

        private readonly ProcessController processController = new ProcessController();

        [Fact]
        public void Should_copy_to_remote()
        {
            processController.Start(new Copy(@"d:\test.txt", @"\\192.168.1.100\ADMIN$"));
        }

        [Fact]
        public void Should_get_process()
        {
            Assert.NotEmpty(remoteProcessController.GetProcesses());
        }

        [Fact]
        public void Should_run_remote_process()
        {
            Assert.True(remoteProcessRunner.Start(new Cmd(@"dir c:\")).StandardOutput.Contains("Le volume dans le lecteur C s'appelle"));
        }

        [Fact]
        public void Should_get_remote_processes()
        {
            Assert.NotEmpty(new TaskList().Execute(remoteProcessRunner));
        }

        [Fact]
        public void Should_get_remote_services()
        {
                var controller = new ProcessController(remoteProcessRunner, new IoAdapter(), new AssemblyAdapter());

                var services = controller.GetServices().ToList();

                Assert.NotEmpty(services);
        }
    }
}
